package cdu.xjj.controller;


import cdu.xjj.pojo.Emp;
import cdu.xjj.pojo.EmpQueryParam;
import cdu.xjj.pojo.PageResult;
import cdu.xjj.pojo.Result;
import cdu.xjj.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * 员工管理
 */

@RestController
@RequestMapping("/emps")
public class EmpController {

    private static final Logger log= LoggerFactory.getLogger(DeptController.class);

    @Autowired
    private EmpService empService;

    /**
     * 条件分页查询方法
     */
    @GetMapping()
    public Result page( EmpQueryParam empQueryParam){
        log.info("条件分页查询：{}" , empQueryParam);
        PageResult<Emp> pageResult=empService.page(empQueryParam);
        return Result.success(pageResult);
    }

    /**
     * 新增员工
     */
    @PostMapping()
    public Result save(@RequestBody Emp emp)
    {
        log.info("新增员工:{}",emp);
        empService.save(emp);
        return Result.success();
    }


}
